package com.ysy.controller;


import com.ysy.context.SecurityContextHolder;
import com.ysy.dto.DelFileReqDTO;
import com.ysy.persimmons.common.response.Response;
import com.ysy.service.FileService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class FileController {

    private static final Logger logger = LoggerFactory.getLogger(FileController.class);

    @Resource
    private FileService fileService;


    @PostMapping(value = "/file/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Response<?> uploadFile(@RequestPart(value = "file") MultipartFile file,@RequestParam(name = "type") Integer type) {
        return fileService.uploadFile(file,type);
    }

    @PostMapping(value = "/file/del")
    public Response<?> delFile(@RequestBody DelFileReqDTO delFileReqDTO ) {
        return fileService.delFile(delFileReqDTO);
    }


}
